<?php
/*
* Author: Nguyen Hai Nam
* Plugin: MenuProduct
* Desc	: Introduce pick.vn and sidle pic
* Date	: 12/12/2011
*/
class MenuProductPlugin extends Pick_Core_Plugin{
	
	function MenuProductPlugin(){
		parent::Pick_Core_Plugin();
		$this->namePlugin = "menuproduct";
		$this->descriptionPlugin = "This is menu of product pages";
	}
	public function getContent(){
		$productcategory = new Pick_Dao_ProductCategory();
		$id = $this->request->get("id");
		// If ID empty, it's will get default...
		if(empty($id)){
			$objproductcategorydefault = $productcategory->getObjects(1, "status=1 AND cid = 0", array('position'=>"ASC"), 1);
			if(isset($objproductcategorydefault['data'][0]) && is_object($objproductcategorydefault['data'][0])){
				$id = $objproductcategorydefault['data'][0]->getField('id');
			}	
		}
		$objCategory = $productcategory->getObject($id);
		$objMenus = $productcategory->getObjects(1, ' cid=0 ', array('position'=>'ASC'));
		$this->template->assign('productcategory', $productcategory);
		$this->template->assign('id', $id);
		$this->template->assign('objCategory', $objCategory);
		$this->template->assign('objMenus', $objMenus['data']);
	}
}